package com.chinairi.mall.controller;


import com.chinairi.common.utils.ResponseUtil;
import com.chinairi.mall.controller.viewobject.TACVO;
import com.chinairi.mall.model.TrackAlarmConfig;
import com.chinairi.mall.service.ITrackAlarmConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.chinairi.common.controller.BaseController;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 节点预警信息配置表 前端控制器
 * </p>
 *
 * @author Webgasd
 * @since 2020-08-17
 */
@RestController
@RequestMapping("/track-alarm-config")
public class TrackAlarmConfigController extends BaseController {
    @Autowired
    private ITrackAlarmConfigService trackAlarmConfigService;

    @GetMapping("/config")
    @ResponseBody
    public void config(TACVO tacvo) throws IOException {
        trackAlarmConfigService.addPoint(tacvo);
        ResponseUtil.showMessage("success","配置成功", null);
    }

    @GetMapping("/update")
    @ResponseBody
    public void update(TACVO tacvo) throws IOException {
        trackAlarmConfigService.updatePoint(tacvo);
        ResponseUtil.showMessage("success","更新成功", null);
    }

    @GetMapping("/delete")
    @ResponseBody
    public void delete(TACVO tacvo) throws IOException {
        trackAlarmConfigService.deletePoint(tacvo.getTrackNumber());
        ResponseUtil.showMessage("success","删除成功", null);
    }

    @GetMapping("/get")
    @ResponseBody
    public void getList(TACVO tacvo) throws IOException {
        List<TrackAlarmConfig> list =trackAlarmConfigService.getPoints(tacvo);
        ResponseUtil.showMessage("success","节点预警配置列表", list);
    }
}
